package com.ymatou.iapi.productlimit.testcase;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ymatou.iapi.productlimit.parameter.OperationProductLimit;
import com.ymatou.iapi.productlimit.parameter.OperationProductLimitBean;
import com.ymatou.iapi.productlimit.parameter.ReturnProductLimitBean;
import com.ymatou.iapi.productlimit.service.GetLimitAllowBuyCall;
import com.ymatou.iapi.productlimit.service.OperationProductLimitCall;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymatou.iapi.userservice.parameter.AddressRequestDtoBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.business.service.ProductLimitCallService;
import com.ymttest.business.service.ProductPriceCallService;
import com.ymttest.database.mongo.ProductsWapper;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.utils.TestDataManager;

/**
 * 下单时设置商品限购信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_OperationProductLimit {
	private static OperationProductLimitBean operationproductlimitBean;
	private static OperationProductLimitCall operationproductlimitCall;
	private static ActivityProductsWapper activityProductsWapper;
	private volatile int count=0;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("下单时设置商品限购信息");
	}

	

	@Before
	public void caseUp() {
		operationproductlimitBean = new OperationProductLimitBean();
		operationproductlimitCall = new OperationProductLimitCall();
		activityProductsWapper = new ActivityProductsWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(operationproductlimitCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 错误的参数会验证limit数值为0
	 * 
	 * @param getlimitallowbuyCall2
	 * @param operationproductlimitBean
	 */
	private void verifyFailed(GetLimitAllowBuyCall getlimitallowbuyCall2, OperationProductLimitBean operationproductlimitBean) {
		// Thread:main 2017-08-11 14:08:02.093
		// 返回报文{"Code":200,"BCode":0,"Msg":"操作成功","Data":{"Results":[{"ProductId":"2467b5d7-47ea-4e38-af2e-5602073c4d4d","LimitNumber":0,"ActivityLimitNumber":1,"BoughtNumber":0,"ActivityBoughtNumber":1,"ProductInActivityLimitNumber":0,"ProductInActivityBoughtNumber":0}]},"Trace":null}
		Map<String, OperationProductLimit> mop = new HashMap<String, OperationProductLimit>();
		// 用于和查询比较
		for (OperationProductLimit topl : operationproductlimitBean.getOperationProductLimitList()) {
			mop.put(topl.getProductId(), topl);
		}
		JsonArray results = getlimitallowbuyCall2.getJsonObject().getAsJsonObject("Data").getAsJsonArray("Results");
		for (JsonElement jsonElement : results) {
			JsonObject jo = jsonElement.getAsJsonObject();
			OperationProductLimit op = mop.get(jo.get("ProductId").getAsString());
			if (op.getActivityId() != null && op.getActivityId() > 0 && op.getProductInActivityId() != null && op.getProductInActivityId() > 0 && op.getBuyCount() != null
					&& op.getBuyCount() > 0) {
				if (op.getActivityLimit() != null && op.getActivityLimit() > 0) {
					Logger.verifyEquals(op.getActivityLimit(), jo.get("ActivityLimitNumber").getAsInt(), "验证ActivityLimitNumber");
					Logger.verifyEquals(0, jo.get("ActivityBoughtNumber").getAsInt(), "验证ActivityBoughtNumber");
				} else if (op.getProductInActivityLimit() != null && op.getProductInActivityLimit() > 0) {
					Logger.verifyEquals(op.getProductInActivityLimit(), jo.get("ProductInActivityLimitNumber").getAsInt(), "验证ProductInActivityLimitNumber");
					Logger.verifyEquals(0, jo.get("ProductInActivityBoughtNumber").getAsInt(), "验证ProductInActivityBoughtNumber");
				}
			}
		}

	}

	private void verifyData(GetLimitAllowBuyCall getlimitallowbuyCall2, OperationProductLimitBean operationproductlimitBean) {
		// Thread:main 2017-08-11 14:08:02.093
		// 返回报文{"Code":200,"BCode":0,"Msg":"操作成功","Data":{"Results":[{"ProductId":"2467b5d7-47ea-4e38-af2e-5602073c4d4d","LimitNumber":0,"ActivityLimitNumber":1,"BoughtNumber":0,"ActivityBoughtNumber":1,"ProductInActivityLimitNumber":0,"ProductInActivityBoughtNumber":0}]},"Trace":null}
		Map<String, OperationProductLimit> mop = new HashMap<String, OperationProductLimit>();
		// 用于和查询比较
		for (OperationProductLimit topl : operationproductlimitBean.getOperationProductLimitList()) {
			mop.put(topl.getProductId(), topl);
		}
		JsonArray results = getlimitallowbuyCall2.getJsonObject().getAsJsonObject("Data").getAsJsonArray("Results");
		for (JsonElement jsonElement : results) {
			JsonObject jo = jsonElement.getAsJsonObject();
			OperationProductLimit op = mop.get(jo.get("ProductId").getAsString());
			if (op.getActivityLimit() != null && op.getActivityLimit() > 0) {
				Logger.verifyEquals(op.getActivityLimit(), jo.get("ActivityLimitNumber").getAsInt(), "验证ActivityLimitNumber");
				Logger.verifyEquals(op.getBuyCount(), jo.get("ActivityBoughtNumber").getAsInt(), "验证ActivityBoughtNumber");
			} else if (op.getProductInActivityLimit() != null && op.getProductInActivityLimit() > 0) {
				Logger.verifyEquals(op.getProductInActivityLimit(), jo.get("ProductInActivityLimitNumber").getAsInt(), "验证ProductInActivityLimitNumber");
				Logger.verifyEquals(op.getBuyCount(), jo.get("ProductInActivityBoughtNumber").getAsInt(), "验证ProductInActivityBoughtNumber");
			}
		}

	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_OperationProductLimit_001() {
		Logger.start(true, "设置活动限购信息成功ActivityLimit,扣减ActivityLimit");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
//			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			// 调用查询接口验证数据
			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_002() {
		Logger.start(true, "设置活动商品限购信息成功ProductInActivityLimit,扣减ProductInActivityLimit");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			// 调用查询接口验证数据
			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_003() {
		Logger.start(true, "不输入productid,查询空结果");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			// operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			// TODO 无法通过查询接口校验 待确认 接口必须要pid
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_004() {
		Logger.start(true, "不输入BuyerId,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			// operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("201", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals("false", operationproductlimitCall.getString("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_005() {
		Logger.start(true, "不输入BuyCount,不扣减");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			// operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_006() {
		Logger.start(true, "不输入ActivityId,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			// operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_007() {
		Logger.start(true, "不输入ProductInActivityId,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			// operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_008() {
		Logger.start(true, "不输入ActivityLimit和ProductInActivityLimit(必须输入1个),失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			// operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_009() {
		Logger.start(true, "BuyCount超出ActivityLimit限制,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setActivityLimit(limit);
			operationProductLimit.setBuyCount(1 + limit);
			operationProductLimit.setProductId(productId);
//			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			Logger.verifyIsContains("超出", operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("OperationMsg").getAsString(), "验证OperationMsg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_010() {
		Logger.start(true, "BuyCount超出ProductInActivityLimit限制,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1 + limit);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			Logger.verifyIsContains("超出", operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("OperationMsg").getAsString(), "验证OperationMsg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_011() {
		Logger.start(true, "多次购买最后一次BuyCount超出ActivityLimit限制,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
//			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			// 调用2次 超限
			operationproductlimitCall.callService();
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			Logger.verifyIsContains("超出", operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("OperationMsg").getAsString(), "验证OperationMsg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_012() {
		Logger.start(true, "多次购买最后一次BuyCount超出ProductInActivityLimit限制,失败");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			// 调用2次 超限
			operationproductlimitCall.callService();
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			Logger.verifyIsContains("超出", operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("OperationMsg").getAsString(), "验证OperationMsg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_013() {
		Logger.start(true, "返还商品限购数量后ActivityLimit再次购买成功");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
//			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			// 调用
			operationproductlimitCall.callService();
			// 返还
			ReturnProductLimitBean rt = ProductLimitCallService.initReturnProductLimitBean(operationproductlimitBean, 1);
			ProductLimitCallService.returnProductLimitCall(rt);
			Thread.sleep(2000);
			// 调用
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_014() {
		Logger.start(true, "返还商品限购数量后ProductInActivityLimit再次购买成功");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
//			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			// 调用
			operationproductlimitCall.callService();
			ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean));
			// 返还
			ReturnProductLimitBean rt = ProductLimitCallService.initReturnProductLimitBean(operationproductlimitBean, 1);
			ProductLimitCallService.returnProductLimitCall(rt);
			ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean));
			Thread.sleep(2000);
			// 调用
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			// ?true
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_015() {
		Logger.start(true, "批量购买活动限购信息成功ActivityLimit,扣减ActivityLimit");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 2;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);

			operationproductlimitBean = ProductLimitCallService.initOperationProductLimitBean(userId, limit, 0, 1, 2);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			// 调用查询接口验证数据
			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_016() {
		Logger.start(true, "批量购买活动商品限购信息成功ProductInActivityLimit,扣减ProductInActivityLimit");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 2;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);

			operationproductlimitBean = ProductLimitCallService.initOperationProductLimitBean(userId, 0, limit, 1, 2);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			// 调用查询接口验证数据
			verifyData(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	// @Test
	// @Category({ P2.class })
	// @TestCase
	// @Ignore
	// 不存在此场景 ActivityLimit和ProductInActivityLimit只会存在1个
	// public void Tc_OperationProductLimit_017() {
	// Logger.start(true,
	// "混合购买活动限购信息成功ActivityLimit和ProductInActivityLimit,扣减ActivityLimit和ProductInActivityLimit");
	// try {
	// org.junit.Assert.fail();
	// operationproductlimitCall.setData(operationproductlimitBean);
	// operationproductlimitCall.callService();
	//
	// } catch (Exception e) {
	// Logger.fail(e);
	// }
	// }

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_OperationProductLimit_018() {
		Logger.start(true, "BuyCount负数,不操作限购数量");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 1;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(-1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_019() {
		Logger.start(true, "批量购买活动限购信息ActivityLimit,其中有一个参数异常失败,事务失败都不操作");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 2;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);

			operationproductlimitBean = ProductLimitCallService.initOperationProductLimitBean(userId, limit, 0, 1, 2);
			operationproductlimitBean.getOperationProductLimitList().get(0).setBuyCount(5);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_OperationProductLimit_020() {
		Logger.start(true, "设置的商品id不在当前有效限购活动中,操作后不会查询出数据");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(1);
			operationProductLimit.setActivityLimit(1);
			operationProductLimit.setBuyCount(1);
			// 随机pid 商品查不出的时候 不会进入数据
			operationProductLimit.setProductId(TestDataManager.getRandomUUID().toString());
			operationProductLimit.setProductInActivityId(1);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(true, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_OperationProductLimit_021() {
		Logger.start(true, "并发设置活动限购信息不会超出");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId =urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			int limit = 10;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);
			operationproductlimitBean.setAppId("autotest");
			operationproductlimitBean.setBuyerId(userId);
			List<OperationProductLimit> operationProductLimitList = new ArrayList<>();
			OperationProductLimit operationProductLimit = new OperationProductLimit();
			operationProductLimit.setActivityId(activityId);
			operationProductLimit.setProductInActivityLimit(limit);
			operationProductLimit.setBuyCount(1);
			operationProductLimit.setProductId(productId);
			operationProductLimit.setProductInActivityId(inaid);
			operationProductLimitList.add(operationProductLimit);
			operationproductlimitBean.setOperationProductLimitList(operationProductLimitList);
			operationproductlimitCall.setData(operationproductlimitBean);

			ExecutorService SERVICE = Executors.newFixedThreadPool(20);
			for (int i = 0; i < 100000; i++) {
				SERVICE.execute(() -> {
					try {
						operationproductlimitCall = new OperationProductLimitCall();
						operationproductlimitCall.setData(operationproductlimitBean);
						operationproductlimitCall.callService();
						count++;
					} catch (Exception e) {
						e.printStackTrace();
					}
				});
			}
			Thread.sleep(60000);
			// 调用查询接口验证数据
			System.out.println(count);
			ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_022() {
		Logger.start(true, "批量购买活动限购信息成功ActivityLimit单个不超出总计超出,被限制");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

//			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
//			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
//			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			List<ProductAllPriceBean> productAllPriceBeanList = ProductPriceCallService.getProdPriceListWithActivity_NewBuyerAndNoIsolation(sellerId,2);
			String productId=productAllPriceBeanList.get(0).getProductId();
			String productId1=productAllPriceBeanList.get(1).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			int limit = 2;
			ProductsWapper p = new ProductsWapper();
			p.updateAlimitByInaid(inaid, limit);

			operationproductlimitBean = ProductLimitCallService.initOperationProductLimitBean(userId, limit, 0, 1, productAllPriceBeanList);
			operationproductlimitBean.getOperationProductLimitList().get(1).setBuyCount(2);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");

			// 调用查询接口验证数据
			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_OperationProductLimit_023() {
		Logger.start(true, "批量购买活动商品限购信息成功ProductInActivityLimit单个不超出总计超出,被限制");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			Integer userId = urrc.getUserid();

			// 固定sellerid制作静态数据
			int sellerId = 3383;

//			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
//			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
//			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			List<ProductAllPriceBean> productAllPriceBeanList = ProductPriceCallService.getProdPriceListWithActivity_NewBuyerAndNoIsolation(sellerId,1);
			String productId=productAllPriceBeanList.get(0).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			Integer activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			int limit = 2;
			ProductsWapper p = new ProductsWapper();
			p.updatePlimitByInaid(inaid, limit);

			operationproductlimitBean = ProductLimitCallService.initOperationProductLimitBean(userId, 0, limit,1 , productAllPriceBeanList);
			operationproductlimitBean.getOperationProductLimitList().add(operationproductlimitBean.getOperationProductLimitList().get(0));
			operationproductlimitBean.getOperationProductLimitList().get(0).setBuyCount(2);
			operationproductlimitCall.setData(operationproductlimitBean);
			operationproductlimitCall.callService();
			Logger.verifyEquals("200", operationproductlimitCall.getString("Code"), "验证Code");
			Logger.verifyEquals(false, operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("IsOperationSuccess").getAsBoolean(), "验证IsOperationSuccess");
			Logger.verifyIsContains("超出活动商品限购数量", operationproductlimitCall.getJsonObject().getAsJsonObject("Data").get("OperationMsg").getAsString(), "验证OperationMsg");

			// 调用查询接口验证数据
//			verifyFailed(ProductLimitCallService.getLimitAllowBuyCall(ProductLimitCallService.initGetlimitallowbuyBean(operationproductlimitBean)), operationproductlimitBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}